package login

import (
	"OnlineRetailers/controllers/errorDeal"
	error2 "OnlineRetailers/models/errorDeal"

	"github.com/astaxie/beego"
	"github.com/dchest/captcha"
)

type VerifyCaptcha struct {
	beego.Controller
}

func (c *VerifyCaptcha) VerifyCaptcha() {

	defer func() {

		c.Ctx.Output.Header("Access-Control-Allow-Origin", "*")
		c.Ctx.Output.Status = 200
		c.Ctx.ResponseWriter.Header().Set("Access-Control-Expose-Headers", "Session")
		c.ServeJSON()
	}()

	//captchaRes:=captcha.Server(captcha.StdWidth, captcha.StdHeight)
	mes := &error2.Mes{}

	id := c.GetString("id")
	value := c.GetString("value")

	if !captcha.VerifyString(id, value) {
		c.Data["json"] = errorDeal.ErrLightMess(mes, "403", "验证码错误")
		return
	}
}

//func VerifyCaptcha() {
//	var captchaId string
//	fmt.Println(captcha.VerifyString(captchaId, captchaId))
//}
